package com.zmn.plat.common.dictionary;

/**
 * 合同状态枚举
 *
 * @author linfeng
 * @since 2020/05/09 14:56:30
 */
public enum ContractStatusEnum {

    /**
     * values
     */
    TOBESIENED(1, "待签订"),
    EXECUTION(2, "执行中"),
    ABORTED(3, "已中止"),
    OBSOLETE(4, "已废弃"),
    EXPIRED(5, "已过期"),
    ARCHIVED(6, "已归档"),
    NOTARCHIVED(7, "未归档");

    private Integer code;
    private String name;

    ContractStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ContractStatusEnum of(Integer code) {
        if (code == null || code == 0) {
            return TOBESIENED;
        }
        switch (code) {
            case 1:
                return TOBESIENED;
            case 2:
                return EXECUTION;
            case 3:
                return ABORTED;
            case 4:
                return OBSOLETE;
            case 5:
                return EXPIRED;
            case 6:
                return ARCHIVED;
            case 7:
                return NOTARCHIVED;
            default:
                return TOBESIENED;
        }
    }
}
